﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinForm_Bankapp
{
    public class Account
    {
        private string accountNumber;//账户的账号
        private decimal balance;//账户的余额

        public string AccountNumber//改变账户的账号
        {
            get { return accountNumber; }
            set { accountNumber = value; }
        }

        public decimal Balance//改变账户的余额
        {
            get { return balance; }
            set { balance = value; }
        }

        public Account(string accountNumber, decimal initialBalance)
        {
            this.accountNumber = accountNumber;
            this.balance = initialBalance;
        }

        public virtual void Withdraw(decimal amount)//余额的更改
        {
            if (amount <= 0)
            {
                throw new ArgumentException("Amount must be greater than zero.");
            }

            if (balance >= amount)
            {
                balance -= amount;
            }
            else
            {
                throw new InsufficientBalanceException("Insufficient balance.");
            }
        }

        public virtual void Deposit(decimal amount)
        {
            if (amount <= 0)
            {
                throw new ArgumentException("Amount must be greater than zero.");
            }

            balance += amount;
        }


    }
}
